//:C07:SuperVar.cpp
// A Super-variable
#include <iostream>
using namespace std;

class SuperVar{
    enum{
        character,
        integer,
        flaoting_point
    } vartype;    // Define one{}

    union{  // Anonymous union
        char c;
        int i;
        float f;
    };
    public:
        SuperVar(char ch);
        SuperVar(int ii);
        SuperVar(flat ff);
        void print();
};

SuperVar::SuperVar(char ch){
    vartype = character;
    c = ch;
}

SuperVar::SuperVar(int ii){
    vartype = integer;
    i = ii;
}

SuperVar::SuperVar(float ff){
    vartype = flaoting_point;
    f = ff;
}

void SuperVar::print(){
    switch(vartype){
        case character:
            cout << "character: " << c << '\n';
            break;
        case integer:
            cout << "integer: " << i << '\n';
            break;
        case flaoting_point:
            cout << "float: " << f << '\n';
            break;
    }
}

int main(void){
    SuperVar A('c'), B(12), C(1.44F);
    A.print();
    B.print();
    C.print();
    return 0;
}



